<?php


namespace app\user\validate;


use think\Validate;

class UserValidate extends Validate
{
    protected $rule = [
        'name|用户名' => 'require',
        'email|邮箱' => 'require|email',
        'password|密码' => 'require',
        'captcha|验证码' => 'require',
        'sex|性别' => 'require|in:0, 1',
        'github_url|github地址' => 'require|max:200',
        'profile|个人描述' => 'max:200',
        'avatar|头像' => ['filesize:102400|fileExt:jpg,png|image:200,200,jpg']
    ];

    protected $message = [
        'avatar.filesize' => '头像大小不能超过102400KB',
        'avatar.fileExt' => '只允许上传jpg, png格式的图片'
    ];

    protected $scene = [
        'login' => ['email', 'password', 'captcha'],
        'register' => ['email', 'password', 'name', 'captcha'],
        'reset' => ['email', 'password', 'captcha'],
        'sendEmailBox' => ['email'],
        'setSelf' => ['name', 'sex', 'github_url', 'profile'],
        'avatar' => ['avatar']
    ];
}